package x.zero.mapper;

import org.beetl.sql.core.page.PageRequest;
import org.beetl.sql.core.page.PageResult;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.SqlResource;

import java.util.List;
import java.util.Map;

@SqlResource("generator")
public interface GeneratorMapper {

    PageResult<Map> pageTable(String name, PageRequest pageRequest);

    @Sql("select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables"
            + " where table_schema = (select database()) ")
    List<Map<String, Object>> list();

    @Sql("select count(*) from information_schema.tables where table_schema = (select database())")
    int count();

    @Sql("select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables \r\n"
            + "	where table_schema = (select database()) and table_name = #{tableName}")
    Map<String, String> get(String tableName);

    @Sql("select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns\r\n"
            + " where table_name = ? and table_schema = (select database()) order by ordinal_position")
    List<Map<String, String>> listColumns(String tableName);
}
